package disksinapile;

import java.util.Arrays;

public class CandidateCode 
{ 
	public static int get_order(int[] a) {
		if(a == null)
			return 0;
		int[] b = a.clone();
		Arrays.sort(b);
		int n = a.length - 1;
		for(int i = a.length - 1; i >= 0; i--)
			if(b[n] == a[i])
				n--;
		return n + 1;
	}

	public static void main(String[] args) {
		int[] l1 = {3, 4, 5, 2, 1};
		System.out.println(get_order(l1));
		int[] l2 = {5, 2, 3, 6};
		System.out.println(get_order(l2));
	}
}
